<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE head PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/static/include/common.inc"%>
<link rel="stylesheet" href="static/admin/css/layui.css">
<link rel="stylesheet" href="static/admin/css/main.css" media="all">
<link rel="stylesheet" href="static/layui_v2.2.3/css/zbyui.css">
<script src="static/js/jquery-1.11.2.js"></script>
<script src="static/layui_v2.2.3/layui.js"></script>
</head>
<body>
	<form class="layui-form" action="">
		<input type="hidden" name="id" value="${typeObj.id }" id="id">
		<div class="layui-form-item">
			<label class="layui-form-label">类型</label>
			<div class="layui-input-block" style="z-index: 9999;">
				<select name="parentId" lay-verify="required">
					<option value="0">父类型</option>
					<c:forEach items="${ptypes }" var="type">
						<option value="${type.id }" ${type.id==typeObj.parentId?"selected='selected'":"" }>${type.name }</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">类型名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" required lay-verify="required" maxlength="64"
					placeholder="请输入标题" autocomplete="off" class="layui-input" value="${typeObj.name }">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">描述</label>
			<div class="layui-input-block">
				<textarea style="width: 350px;height: 200px;" id="description" name="description">
					${typeObj.description }
				</textarea>
    		</div>
    	</div>
		<div class="layui-form-item">
			<div class="layui-input-block" style="align-items: center;">
				<button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
				<button class="layui-btn layui-btn-primary" id="zby-closeBtn">关闭</button>
			</div>
		</div>
	</form>
	<script type="text/javascript">
	<!-- 实例化编辑器 -->

		layui.use([ 'form', 'laydate' ], function() {
			var form = layui.form;
			//监听提交
			form.on('submit(formDemo)', function(data) {
				$(".layui-btn").addClass("layui-btn-disabled")
				$.ajax({
					type : "post",
					url : "admin/typeManage/updateType.do",
					data : data.field,
					async: false,
					success : function(result) {
						if (result.code == 1) {
							parent.layer.msg(result.msg);
							setTimeout(closeOpt,1500);
						} else {
							parent.layer.msg(result.msg);
						}
					}
				});
				return false;
			});
		});
		function closeOpt(){
			var index=parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
			window.parent.location.reload();
		}
		$("#zby-closeBtn").bind("click",function(){
			var index=parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		})
	</script>
</body>
</html>